package com.huangsm.concurrence.blockingqueue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * 使用BlockingQueue的例子
 *
 * @author huang
 * @date 2019/2/14
 * 详细参考 https://blog.csdn.net/defonds/article/details/44021605
 */
public class BlockingQueueExample {


    public static void main(String[] args) throws Exception {
        //设置1024容量大小的阻塞队列
        BlockingQueue queue = new ArrayBlockingQueue(1024);
        Producer producer = new Producer(queue);
        Cousumer cousumer = new Cousumer(queue);
        new Thread(producer).start();
        new Thread(cousumer).start();
        Thread.sleep(3000);

    }
}
